var nowPoint = null
var map = null
var marker1 = null



setInterval(function () {
    var date = new Date();
    var year = date.getFullYear(); //获取当前月份  
    var mon = date.getMonth() + 1; //获取当前月份  
    var day = date.getDate(); //获取当前日  
    var h = date.getHours(); //获取小时  
    var m = date.getMinutes(); //获取分钟  
    var s = date.getSeconds(); //获取秒  
    if (mon < 10) mon = "0" + mon;
    if (h < 10) h = "0" + h;
    if (m < 10) m = "0" + m;
    if (s < 10) s = "0" + s;
    var current_time = '#' +
        year + '-' + mon + '-' + day + ' ' + h + ':' + m

    $(".ub-time").html(current_time)
}, 1000)

var vue = new Vue({
    el: "#main",
    data() {
        return {
            isShow: false,
            isShowAll: false,
            userInfo: {},
            content: [],
            images: [],
            list: [],
        }
    },
    created() {
        this.id = getRequest().id
        this.getRecords()
        this.getSeekManInfo()
    },
    mounted() {

    },
    methods: {
        // 获取老人详情
        getSeekManInfo() {
            ajax({
                url: formal + '/sick-man/get-sick-man/' + this.id,
                type: 'GET',
                success: (res) => { //请求成功回调
                    this.userInfo = res
                },
            })
        },
        // 关爱记录
        getRecords() {
            ajax({
                url: formal + '/sick-man/get-care/' + this.id,
                type: 'GET',
                success: (res) => {
                    res.data.forEach(element => {
                        element.flage = true
                        element.data.forEach(item => {
                            item.flage = false
                            item.care.forEach(el => {
                                el.flage = false
                                el.img = []
                                el.image_list.forEach(item => {
                                    el.img.push(item)
                                })
                                el.phone_image_list.forEach(item => {
                                    el.img.push(item)
                                })
                            })
                        })
                    });
                    this.list = res.data
                }
            })
        },
        // 老版本关爱记录
        // getRecords() {
        //     ajax({
        //         url: formal + '/sick-man/get-sick-man-care/' + this.id,
        //         type: 'GET',
        //         success: (res) => {
        //             res.data.list.forEach(el => {
        //                 el.img = []
        //                 el.image_list.forEach(item => {
        //                     el.img.push(item.url)
        //                 })
        //                 el.phone_image_list.forEach(item => {
        //                     el.img.push(item.url)
        //                 })
        //             });
        //             this.list = res.data.list
        //         }
        //     })
        // },
        // 查看图片
        lookImg(list, current) {
            wx.previewImage({
                current: current, // 当前显示图片的 http 链接
                urls: list // 需要预览的图片 http 链接列表
            });
        },
        goBack() {
            history.back()
        }
    }
})